﻿var currentPage = 1; // 当前页
var pageSize = 6; // 每页显示多少条
var pageall = 0; // 总页数
var total = 0; // 总记录数
var IdList = "";
var arrstr = "";
var photocount = 0;
var photocountHXT = 1;

$(document).ready(function() {
    var id = LexunJS.GetQueryString("id"); // 楼盘ID
    if (id > 0) $("#hID").val(id);

    //ShowType(); // 加载房屋设施列表
    showDetail(id);
    // 默认标签
    var tagNo = LexunJS.GetQueryString("tagNo");
    if (parseInt(tagNo) <= 0 || tagNo == "") tagNo = 3;
    tagNo = parseInt(tagNo);

    go_to(tagNo);
});

//加载房屋设施列表
function ShowType() {
    var type = "房屋设施";  qz
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=ListByType&type=' + type,
        timeout: '10000',
        error: function() {
            alert("修改失败！");
        },
        success: function(json) {
            showAppliancesCallBack(json);
        }
    });
}

function showAppliancesCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) return;
    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        arrstr += record[i].item + ",";
    }
}

// 查询详细
function showDetail(id) {
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=housing_detail&id=' + id,
        timeout: '10000',
        error: function() {
            alert("修改失败！");
        },
        success: function(json) {
            showDetailCallBack(json);
        }
    });
}

function showDetailCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) return;

    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        $("#sId").text(record[i].id);
        $("#sDname").text(record[i].area + record[i].dname);
        $("#sBuildName").text(record[i].ename + record[i].buildname);
        $("#sRoomNo").text(record[i].mark1 + "楼 " + record[i].roomno);
        $("#sAcreage").text(record[i].acreage);


        $("#tradetype").val(record[i].tradetype);
        if (record[i].tradetype == 1) {
            $("#sTradetype").text("出售");
            $("#sTotalprice").text("售："+record[i].totalprice + " 万");
            $("#sUnitPrice").text("单价:" + ((record[i].totalprice / record[i].acreage)*10000).toFixed(2) + "元");
        } else if (record[i].tradetype == 2) {
            $("#sTradetype").text("出租");
            $("#sTotalprice").text("租："+record[i].leaseprice + " 元/月");
            $("#sUnitPrice").text("单价:" + (record[i].leaseprice / record[i].acreage).toFixed(2) + "元");
        } else if (record[i].tradetype == 3) {
            $("#sTradetype").text("租售");
            $("#sTotalprice").text("售:" + record[i].totalprice + " 万 租:" + record[i].leaseprice + " 元/月");
        }        
              
        //$("#sRegisterDate").text(record[i].registerdate); //房龄

        var useValue = "";
        var useStr = record[i].use;
        if (useStr == "2") {//用途是商铺，显示租客
            document.getElementById("divHx").style.display = "none";
            document.getElementById("divRentCust").style.display = "";
            $("#sRoomHall").text(record[i].tenant); //租客
            var assignmentfee = record[i].assignmentfee;
            if (assignmentfee != "0") {
                document.getElementById("divCx").style.display = "none";
                document.getElementById("divZrf").style.display = "";
                $("#sDirect").text(record[i].assignmentfee+"万"); //转让费
            } else {
                document.getElementById("divCx").style.display = "";
                document.getElementById("divZrf").style.display = "none";
                $("#sDirect").text(record[i].direct);
            }
        } else {
            document.getElementById("divHx").style.display = "";
            document.getElementById("divRentCust").style.display = "none";
            
            document.getElementById("divCx").style.display = "";
            document.getElementById("divZrf").style.display = "none";
            $("#sDirect").text(record[i].direct);
            $("#sRoomHall").text(record[i].room + "房" + record[i].hall + "厅" + record[i].restroom + "卫" + record[i].balcony + "阳台");

         }


        $("#sUse").text(LexunJS.GetUsageNameById(useStr));
        $("#sHouseType").text(record[i].housetype);
        $("#sHouseStyle").text(record[i].housestyle);
        $("#sPropertyRight").text(record[i].propertyright);
        $("#sPocNo").text(record[i].pocno);
        $("#sSource").text(record[i].source);
        $("#sFitment").text(record[i].fitment);
        $("#sUseStatus").text(record[i].usestatus);
        //        if (record[i].haskey == 0)
        //            $("#sHasKey").text("否");
        //        else
        //            $("#sHasKey").text("是");
        $("#skeepKeyDate").text(record[i].keepkeydate);
        $("#sKeyNo").text(record[i].keyno);
        $("#sKeepKey").text(record[i].keepkey);
        if (record[i].ctycont == 0) $("#sCtyCont").text("未反签");
        else $("#sCtyCont").text("已反签");
        $("#sCtyContUser").text(record[i].ctycontuser);
        $("#sCtyContDate").text(record[i].ctycontdate);

        if (record[i].isonly == 0) $("#sIsOnly").text("非独家");
        else $("#sIsOnly").text("独家");
        $("#sOnlyUser").text(record[i].onlyuser);
        $("#sOnlyDate").text(record[i].onlydate);
        $("#sMarkUser").text(record[i].markuser);
        $("#sMarkDate").text(record[i].markdate);
        if (record[i].markudept != "")
            $("#sMarkUdept").text("[" + record[i].markudept + "]");

        if(record[i].keyno != "")
            $("#spankeyno").text("钥匙编号：" + record[i].keyno);
        
        if(record[i].isonly == 1)
            $("#spanisonly").text("独家");        

        if (record[i].pocstatus == '红本')
            $("#spanpocstatus").text("红本在手");        

        if (record[i].mark2 == '满5年免税')
            $("#spanmark2").text("满5年免税");     
    
        var statusText = "";
        if (record[i].status == 1)
            statusText = "当前盘";
        else if (record[i].status == 2)
            statusText = "资料盘";
        else if (record[i].status == 3)
            statusText = "无效盘";

        if (record[i].isvalid == 0)
            statusText += "(有效)";
        else if (record[i].isvalid == 1)
            statusText += "(待审核)";
        else if (record[i].isvalid == 2)
            statusText += "(无效)";

        $("#spanStatus").text(statusText);

        if (record[i].whetherlease =="True")
            $("#sWhetherLease").text("带租约");
        else
            $("#sWhetherLease").text("不带租约");

        if (record[i].inlease == "True")
            $("#sInLease").text("是");
        else
            $("#sInLease").text("否");

        if (record[i].settle == "True")
            $("#sSettle").text("可落户");
        else
            $("#sSettle").text("不可落户");

        if (record[i].degree == "True")
            $("#sDegree").text("带学位");
        else
            $("#sDegree").text("不带学位");

        $("#trueArea").text(record[i].truearea);//使用面积
            
        
        $("#sRentNumber").text(record[i].rentnumber);
        $("#sDepositNumber").text(record[i].depositnumber);
        $("#sAge").text(record[i].age);                       

        if (record[i].protected == 1) $("#spanStatus1").text("已封盘");
        else $("#spanStatus1").text("正常");

        if (record[i].status1 == 1) $("#spanStatus1").text("成交封盘");

        $("#sUDDate").text(record[i].uddate);
        $("#sClickCount").text(record[i].clickcount);
        //$("#spanAroundconditon").text(record[i].aroundcondition);
        //$("#spanTrafficcondition").text(record[i].trafficcondition);
        //$("#spanEstate_remark").text(record[i].estate_remark);
        $("#sAddDate").text(record[i].adddate);
        $("#sAddUser").text(record[i].adduser);
        $("#sPropertyFare").text(record[i].propertyfare);
        $("#sPocStatus").text(record[i].pocstatus);
        $("#sMark2").text(record[i].mark2);
        $("#sRemark").text(record[i].remark);

        // div5中显示的信息
        $("#div5_sArea").text(record[i].area);
        $("#div5_sDname").text(record[i].dname);
        $("#div5_sUse").text(LexunJS.GetUsageNameById(record[i].use));
        $("#div5_sBuildName").text(record[i].estate_name);

        ///标记无效
        var IsValid = record[i].mark4;
        if (IsValid == 1) {
            $("#sIsValid").html("已经标记为无效盘,是否取消:");
            $("#lbtMark").html("[取消]");
            $("#sIsValid").css({ color: 'red' });
            document.getElementById("Mark").value = "0";
        }
        else {
            document.getElementById("Mark").value = "1";
            $("#sIsValid").html("标记为无效盘:");
            $("#lbtMark").html("[标记]");
            $("#sIsValid").css({ color: 'black' });
        }

        var minTotalPrice = 0; // 最小售价
        var maxTotalPrice = 0; // 最高售价
        var minLeasePrice = 0; // 最低租价
        var maxLeasePrice = 0; // 最高租价
        var minAcreage = 0; // 最小面积
        var maxAcreage = 0; // 最大面积
        if (record[i].totalprice < 10) {
            minTotalPrice = (record[i].totalprice * 100 / 100);
            maxTotalPrice = (record[i].totalprice * 100 / 100) + 5;
        } else {
            minTotalPrice = (record[i].totalprice * 100 / 100 - parseInt(record[i].totalprice * 0.1)) * 100 / 100;
            maxTotalPrice = (record[i].totalprice * 100 / 100 + parseInt(record[i].totalprice * 0.1)) * 100 / 100;
        }

        if (record[i].leaseprice < 10) {
            minLeasePrice = (record[i].leaseprice * 100 / 100);
            maxLeasePrice = (record[i].leaseprice * 100 / 100) + 5;
        } else {
            minLeasePrice = record[i].leaseprice * 100 / 100 - parseInt(record[i].leaseprice * 0.1) * 100 / 100;
            maxLeasePrice = record[i].leaseprice * 100 / 100 + parseInt(record[i].leaseprice * 0.1) * 100 / 100;
        }

        if (record[i].acreage < 10) {
            minAcreage = (record[i].acreage * 100 / 100);
            maxAcreage = (record[i].acreage * 100 / 100) + 5;
        } else {
            minAcreage = record[i].acreage * 100 / 100 - parseInt(record[i].acreage * 0.1) * 100 / 100;
            maxAcreage = record[i].acreage * 100 / 100 + parseInt(record[i].acreage * 0.1) * 100 / 100
        }

        if (record[i].tradetype == 1) {
            $("#div5_sTradetype").text("求购");
            $("#div5_sMinTotalPrice").text(minTotalPrice);
            $("#div5_sMaxTotalPrice").text(maxTotalPrice);
            $("#div5_unit").text("万");
        } else if (record[i].tradetype == 2) {
            $("#div5_sTradetype").text("求租");
            $("#div5_sMinLeasePrice").text(minLeasePrice);
            $("#div5_sMaxLeasePrice").text(maxLeasePrice);
            $("#div5_unit").text("元");
        } else if (record[i].tradetype == 3) {
            $("#div5_sTradetype").text("租售");
            $("#div5_sMinTotalPrice").text(minTotalPrice);
            $("#div5_sMaxTotalPrice").text(maxTotalPrice);
            $("#div5_unit").text("万");
        }

        $("#div5_sMinAcreage").text(minAcreage);
        $("#div5_sMaxAcreage").text(maxAcreage);
        $("#div5_sRoomHall").text(record[i].room);
        $("#div5_sDirect").text(record[i].direct);


        //div6的信息
        $("#price").val(record[i].totalprice);

        //div9的信息
        if (record[i].haskey == "1") {
            $("#HLShowKey").show();
            $("#RegisterKey").hide();
            $("#KeyInfo").show();
            $("#KeyInfo").html("钥匙编号:" + record[i].keyno + "  钥匙所有人:" + record[i].keepkey);
        }
        else {
            $("#HLShowKey").hide();
            $("#RegisterKey").show();
            $("#KeyInfo").hide();
        }

        // 待审提示【温馨提示：已申请转当前盘待审核,不允许转盘。】
        if (record[i].isvalid == 1) $("#sOutmsg").html("<font color='red'>【温馨提示：待审核盘源,不允许转盘。】</font>");
        if (record[i].status1 == 2) $("#sOutmsg").html("<font color='red'>【温馨提示：已申请转当前盘待审核,不允许转盘。】</font>");
        if (record[i].status1 == 3) $("#sOutmsg").html("<font color='red'>【温馨提示：已申请转当前盘待审核,不允许转盘。】</font>");

        ///遍历房屋设施;
        //        var list = record[i].happliances;
        //        if (list == null) {
        //            return;
        //        } else {
        //            var arr = new Array();
        //            arr = list.split(',');
        //            var arrlist = new Array();
        //            arrstr = arrstr.substr(0, arrstr.length - 1);
        //            var arrlist = "";
        //            arrlist = arrstr.split(',');
        //            var strarr = "";
        //            for (var i = 0; i < arr.length; i++) {
        //                var arrInputControls;
        //                arrInputControls = document.getElementsByName("hAppliances");
        //                if (arr[i] == "1") {
        //                    strarr += arrlist[i] + ",";
        //                }

        //            }
        //            strarr = strarr.substr(0, strarr.length - 1);
        //            document.getElementById("spanHappliances").innerText = strarr;
        //        }

    }
}

// 跳转 num(跳到第几个标签)
function go_to(num) {
    var tabs = document.getElementById("div_tab").getElementsByTagName("a");

    for (var i = 1; i <= tabs.length; i++) {
        if (num == i) {
            tabs[i - 1].className = "y";
            document.getElementById("div" + i).style.display = "block";
        } else {
            tabs[i - 1].className = "";
            document.getElementById("div" + i).style.display = "none";
        }
    }

    var id = $("#hID").val();
    switch (num) {
        case 1:
            showDetail(id);                 // 房源详情
            break;
        case 2:
            isTelLog(1);                    // 查看电话号码
            break;
        case 3:
            ShowFollow(1);                  // 跟进记录
            break;
        case 4:
            showHousingPic('div4List');     // 房屋照片
            break;
        case 5:
            showCustomer(1);                // 匹配出的客源
            break;
        case 6:
            ShowCalculator(id);             // 贷款税费
            break;
        case 7:
            //ShowInfo(1);                  // 同业主盘源
            showOtherHousing(1);
            break;
        case 8:
            ShowAlert(1);                   // 提醒记录
            break;
        case 9:
            ShowKeys('div9');               // 钥匙管理
            break;
        case 10:
            document.getElementById("tag10").style.display = "block";
            ShowTranctionDetail();          // 成交信息
            break;
    }
}

// 贷款税费
function ShowCalculator(id) {
    $("#div6_loading").hide();
    $('#daikuantype').change();
    if ($("#calc1_radio1").attr('checked') == true) {
        $('#calc1_radio1').click();
    }
    if ($("#calc1_radio2").attr('checked') == true) {
        $('#calc1_radio2').click();
    }
    $('#anjieyears').change();
    exc_lilv();
    $('#calculate_loan').click();
}

function CalculatorCallBack(response) {

    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) return;

    var recordLength = record.length;
    var totalprice = 0
    for (var i = 0; i < recordLength; i++) {
        totalprice = record[i].totalprice;
    }

    $("#div6_loading").hide();
    $("#price").val(totalprice);
    $('#daikuantype').change();
    if ($("#calc1_radio1").attr('checked') == true) {
        $('#calc1_radio1').click();
    }
    if ($("#calc1_radio2").attr('checked') == true) {
        $('#calc1_radio2').click();
    }
    $('#anjieyears').change();
    exc_lilv();
    $('#calculate_loan').click();

}

// 判断是否已被封盘

var ecxl = 0;//等于1的就打开窗口，ajax返回就为0，点击一次加一次。延时就不打开
function isTelLog() {
    var protectedClass = document.getElementById("hProtectedClass").value;
    var station = document.getElementById("hStation").value;
    var manager = document.getElementById("isManager").value;
    var isLock = document.getElementById("hIsLock").value;//0:不封盘，1,：封盘

    if (isLock == "1") {
        if (protectedClass == "区域经理") {
            if (station!="营运总监" && station != "营业总经理" && station != "营运副总监" && station != "区域经理" && station != "分区经理" && manager != "admin") {
                $("#div2").html("<strong><font color='red'>对不起，该业主电话仅对区经以上开放！</font></strong>");

                return false;
            }
        }
        else if (protectedClass == "分行经理") {
        if (station != "营运总监" && station != "营业总经理" && station != "营运副总监" && station != "分行经理" && station != "分区经理" && station != "区域经理" && manager != "admin") {
                $("#div2").html("<strong><font color='red'>对不起，该业主电话仅对分行经理开放！</font></strong>");
                return false;
            }
        }

    }
    var isShowTel = $("#hCompetencesIsShowTel").val();
    if (isShowTel == 0) {
        $("#div2").html("<strong><font color='red'>您无权查看电话!</font></strong>");
        return false;
    }

    var id = LexunJS.GetQueryString("id");
    if (parseInt(id) <= 0 || id == "") {
        $("#div2").html("<strong><font color='red'>请先选择您要查看的房源</font></strong>");
        return false;
    }
    ecxl++;
    if (ecxl == 1) {
        $.ajax({
            type: 'POST',
            url: '../Handler/HandlerHousing.ashx',
            data: 'act=housing_detail&id=' + id,
            timeout: '10000',
            error: function() {
                alert("修改失败！");
            },
            success: function(json) {
                ecxl = 0;
                isTelLogCallBack(json);
            }
        });
    }
    else {
        alert('请稍后 正在打开！');
    }
   
}

function isTelLogCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) return;

    var isManager = $("#hCompetencesIsSalesManagerStation").val();  // 1分行经理及以上级别

    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        if (record[i].protected == 1 && isManager != 1) {
            $("#div2").html("<strong><font color='red'>温馨提示：已被封盘保护,暂不能查看电话！</font></strong>");
            return false;
        } else if (record[i].status1 == 1 && isManager != 1) {
            $("#div2").html("<strong><font color='red'>温馨提示：已成交封盘,暂不能查看电话！</font></strong>");
            return false;
        }
        else {
            // 填充查看电话记录中的数据                
            //$("#span_1").text(record[i].dname + record[i].area);
            //$("#span_2").text(record[i].buildname);
            //$("#span_3").text(record[i].roomno);
            //$("#span_4").text(record[i].totalprice);
            $("#span_owner").text(record[i].owner);
            //            $("#span_ownertel").text(record[i].ownertel);
            $("#span_linkman").text(record[i].linkman);
            //            $("#span_linkmantel").text(record[i].linkmantel);

            showTelLog(1);
        }
    }
}

// 显示是看电话记录
function showTelLog(currentPage) {
    var id = LexunJS.GetQueryString("id");

    $("#div2_list").html(""); // 显示列表
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=tellog_list&id=' + id + '&page=' + currentPage + '&pagesize=' + pageSize,
        timeout: '10000',
        error: function() {
            alert("修改失败！");
        },
        success: function(json) {
            if (json == "1") {
                // json = 1:单个房源1天被查看的次数 2:置业顾问今天已查看电话量
                $("#div2").html("<strong><font color='red'>温馨提示：此房源的查看电话数已达上限,为了保护业主,您暂时无法查看该业主电话，请联系直属经理查看！</font></strong>");
            } else if (json == "2") {
                $("#div2").html("<strong><font color='red'>温馨提示：您今天的查看电话数已达上限！</font></strong>");
            }
            else {
                showTelLogCallBack(json);
            }
        }
    });
}

function showTelLogCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) return;

    var arr = [];
    arr.push("<table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("查阅时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("部门</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("查阅人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("今日查阅总数</td>");
    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");
        else
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");

        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].lookdate + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].dept + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].looker + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push(record[i].nums + "</td>");
        arr.push("</tr>");
    }
    arr.push("</table>");

    $("#div2_list").html(arr.join('')); // 显示列表
    
    // 查看电话号码后必须打更进 
    //var newid = ShowDialogFlow(0);
}

//默认查询跟进
function ShowFollow(currentPage) {
    var id = LexunJS.GetQueryString("id");

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=SelectFollow&id=' + id + '&page=' + currentPage + '&pagesize=' + pageSize + '&refresh=1',
        timeout: '30000',
        error: function() {
            alert("查询失败！");
        },
        success: function(json) {
            ShowFlowCallBack(json);
        }
    });
}

//点击刷新,查询跟进
function ShowFollow1(currentPage) {
    var id = LexunJS.GetQueryString("id");

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=SelectFollow&id=' + id + '&page=' + currentPage + '&pagesize=' + pageSize + '&refresh=1',
        timeout: '30000',
        error: function() {
            alert("查询失败！");
        },
        success: function(json) {
            ShowFlowCallBack(json);
        }
    });
}

// 查询更多跟进
function ShowFollow2(currentPage) {
    var id = LexunJS.GetQueryString("id");  
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=SelectFollow&id=' + id + '&page=' + currentPage + '&pagesize=1000&refresh=1',
        timeout: '30000',
        error: function() {
            alert("查询更多失败！");
        },
        success: function(json) {
            ShowFlowCallBack(json);
        }
    });
}

function ShowFlowCallBack(response) {

    var json = eval("(" + response + ")");
    var record = json.record;
    
    
    
    var page = json.page;

    currentPage = page.currentpage;
    pageall = parseInt(page.pageall);
    total = page.total;

    if (record == null || record.length == 0) {
        $("#divPage").html("<a href=\"javascript:ShowFollow1(1)\">刷新</a><a href=\"javascript:ShowFollow2(1)\">更多...</a>");
        return;
    }

    $("#divList").html(""); // 显示列表
       
    var arr = [];
    arr.push("<table id='table1' style=\"word-break: break-all;\" width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<input type=\"checkbox\" name=\"checkboxAll\" id=\"checkboxAll\" onclick=\"cbSelectAll()\" />");
    arr.push("</td>");
    arr.push("<td width='120px' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("跟进时间</td>");
    arr.push("<td width='80px' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("部门</td>");
    arr.push("<td width='50px' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("跟进人</td>");
    arr.push("<td width='50px' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("跟进类型</td>");
    arr.push("<td bgcolor='d3eaef' class='STYLE10'>");
    arr.push("跟进内容</td>");
    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");
        else
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");

        arr.push("<td  class='STYLE10'>");
        arr.push("<input type='checkbox' name='checkbox_" + record[i].id + "' id='" + record[i].id + "' onclick=\"cbSelect(this, " + record[i].id + ")\" />");
        arr.push("</td>");
        arr.push("<td class='STYLE10'>");
        arr.push("" + record[i].fdate + "</td>");
        arr.push("<td  class='STYLE10'>");
        arr.push("" + record[i].fdept + "</td>");
        arr.push("<td  class='STYLE10'>");
        arr.push("" + record[i].fuser + "</td>");
        arr.push("<td  class='STYLE10'>");
        arr.push("<font color='blue'>" + record[i].followtype + "</font></td>");
        arr.push("<td  class='STYLE7'>");
        arr.push("" + record[i].fcontent + "");
        if (record[i].fimportant != "") {
            arr.push("&nbsp;&nbsp;重要备注：<font color='red'>" + record[i].fimportant + "</font>");
        }
        arr.push("</td>");


        arr.push("</tr>");
    }
    arr.push("</table>");


    
    $("#divList").html(arr.join('')); // 显示列表
    $("#divPage").html(""); // 清空

    $("#divPage").html("<a href=\"javascript:ShowFollow(1)\">刷新</a><a href=\"javascript:ShowFollow2(1)\">更多...</a>");
}

//提交跟进
function submitOk() {
    var housingId = LexunJS.GetQueryString("id");

    var fcontent = document.getElementById("fContent").value;
    var fImportant = document.getElementById("fImportant").value;
    if (LexunJS.Trim(fcontent) == "") {
        alert("请输入跟进内容！");
        return false;
    }

    var followType = LexunJS.GetSelectText("followType");
    var fprice = $("#fprice").val();
    var funitprice = $("#funitprice").val();
    var tradetype = $("#tradetype").val();

    var fdeptId = document.getElementById("ddeptid").value;
    var fdept = document.getElementById("ddept").value;
    var fUserId = document.getElementById("duserid").value;
    var fUser = document.getElementById("duser").value;

    $("#btnOK").attr("disabled", "true");
    $("#btnOK").attr("value", "正在提交...");

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=HFollow2&housingId=' + housingId + '&fcontent=' + escape(fcontent) + '&fImportant=' + escape(fImportant) + '&followType=' + escape(followType) + '&fprice=' + fprice + '&funitprice=' + funitprice + '&tradetype=' + tradetype + '&fdeptId=' + fdeptId + '&fdept=' + fdept + '&fUserId=' + fUserId + '&fUser=' + fUser,
        timeout: '20000',
        error: function() {
            alert("跟进失败！");
            $("#btnOK").removeAttr("disabled");
            $("#btnOK").attr("value", "提交");
        },
        success: function(json) {
            $("#btnOK").removeAttr("disabled");
            $("#btnOK").attr("value", "提交");
            if (json != "")
                alert(json);

            document.getElementById("fContent").value = "";
            ShowFollow(1);
        }
    });
}

// 选中某行
function selectedTr(id) {
    $("tr").removeClass("selected");
    $("#tr_" + id).addClass("selected");

    return false;
}


//查询提醒信息
function ShowAlert(currentPage) {
    var id = LexunJS.GetQueryString("id");
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=ShowAlert&id=' + id + '&page=' + currentPage + '&pagesize=' + pageSize,
        timeout: '10000',
        error: function() {
            alert("修改失败！");
        },
        success: function(json) {
            ShowAlertCallBack(json);
        }
    });
}

function ShowAlertCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    var page = json.page;
    currentPage = page.currentpage;
    pageall = parseInt(page.pageall);
    total = page.total;
    $("#divInfo1").html("");
    if (record == null || record.length == 0) return;
    var arr = [];
    arr.push("<table id='tableList' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10' style='cursor: pointer;'>");
    arr.push("<input type=\"checkbox\" name=\"checkboxAlls\" id=\"checkboxAlls\" onclick=\"cbSelectAlls()\" />");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("人员</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("部门</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("提醒时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("提醒类型</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("提醒内容</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理标志</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理部门</td>");

    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");
        else
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");

        arr.push("<td height='25' class='STYLE10'>");
        arr.push("<input type='checkbox' name='checkbox_" + record[i].id + "' id='" + record[i].id + "' onclick=\"cbSelect(this, " + record[i].id + ")\" />");
        arr.push("</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].adduser + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].adddept + "</td>");
        arr.push("<td height='25' class='STYLE10'>");
        arr.push("" + record[i].alertdate.substr(0, 10) + "</td>");
        arr.push("<td height='25' class='STYLE10'>");
        arr.push("" + record[i].alerttype + "</td>");
        arr.push("<td height='25' class='STYLE7'>");
        arr.push("" + record[i].alertcontent + "</td>");
        if (record[i].dflag == 1) {
            arr.push("<td height='25'  class='STYLE10'>");
            arr.push("<font color='red'>已处理</font></td>");
        } else {
            arr.push("<td height='25'  class='STYLE10'>");
            arr.push("<font color='red'>未处理</font></td>");
        }

        arr.push("<td height='25'  class='STYLE10'>");
        if (record[i].dflag == 1) {
            arr.push("" + record[i].ddate + "</td>");
        } else {
            arr.push("</td>");
        }
        arr.push("<td height='25' class='STYLE10'>");
        arr.push("" + record[i].duser + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].ddept + "</td>");
        arr.push("</tr>");
    }
    arr.push("</table>");
    $("#divInfo1").html(arr.join('')); // 显示列表
    $("#divInfo2").html(""); // 清空
    if (pageall > 1) {
        var pageHtml = LexunJS.showPage2(currentPage, pageall, "ShowAlert"); // 分页
        $("#divInfo2").html(pageHtml);
    }
}

//查询举报信息
function ShowInfo(currentPage) {
    var id = LexunJS.GetQueryString("id");
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=ShowInfo&id=' + id + '&page=' + currentPage + '&pagesize=' + pageSize,
        timeout: '10000',
        error: function() {
            alert("修改失败！");
        },
        success: function(json) {
            ShowInfoCallBack(json);
        }
    });
}

function ShowInfoCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    var page = json.page;

    currentPage = page.currentpage;
    pageall = parseInt(page.pageall);
    total = page.total;
    if (record == null || record.length == 0) return;

    var arr = [];

    arr.push("<table id='tableList' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<input type=\"checkbox\" name=\"checkboxAll\" id=\"checkboxAll\" onclick=\"cbSelectAll()\" />");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("举报时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("部门</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("举报人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("举报内容</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("建议处理</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("处理结果</td>");
    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");
        else
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");

        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("<input type='checkbox' name='checkbox_" + record[i].id + "' id='" + record[i].id + "' onclick=\"cbSelect(this, " + record[i].id + ")\" />");
        arr.push("</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].informdate + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].informdept + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].informuser + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("<font color='blue'>" + record[i].reason + "," + record[i].dview + "</font></td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].advise + "</td>");

        arr.push("<td height='25'  class='STYLE10'>");
        if (record[i].duser == "") {
            arr.push("</td>");
        } else {
            arr.push("" + record[i].ddate + "</td>");
        }
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].duser + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        if (record[i].dresult == "") {
            arr.push("<font color='red'>待审核</font></td>");
        } else {
            arr.push("" + record[i].dresult + "</td>");
        }
        arr.push("</tr>");
    }
    arr.push("</table>");
    $("#divAlert1").html(arr.join('')); // 显示列表
    $("#divAlert2").html(""); // 清空
    if (pageall > 1) {
        var pageHtml = LexunJS.showPage2(currentPage, pageall, "ShowInfo"); // 分页
        $("#divAlert2").html(pageHtml);
    }
}

// 匹配出的客源
function showCustomer(currentPage) {
    var id = LexunJS.GetQueryString("id"); // 楼盘ID
    if (id <= 0) {
        alert("请先选择您要操作的行！");
        return;
    }

    var dname = ""; // 城区
    var area = ""; // 片区
    if (document.getElementById("cbDname").checked) {
        dname = $("#div5_sDname").text();
        area = $("#div5_sArea").text();
    }

    var usage = ""; // 用途
    if (document.getElementById("cbUse").checked) usage = $("#div5_sUse").text();

    var buildname = ""; // 栋阁名称
    if (document.getElementById("cbBuildName").checked) buildname = $("#div5_sBuildName").text();

    var tradetype = ""; // 出售 | 出租
    if (document.getElementById("cbTradetype").checked) tradetype = $("#div5_sTradetype").text();

    var minPrice = 0;
    var maxPrice = 0
    if (document.getElementById("cbTotalPrice").checked) {
        minPrice = $("#div5_sMinTotalPrice").text();
        maxPrice = $("#div5_sMaxTotalPrice").text();
    }

    var minAcreage = 0;
    var maxAcreage = 0
    if (document.getElementById("cbAcreage").checked) {
        minAcreage = $("#div5_sMinAcreage").text();
        maxAcreage = $("#div5_sMaxAcreage").text();
    }

    var room = ""; // 房
    if (document.getElementById("cbRoomHall").checked) room = $("#div5_sRoomHall").text();

    var direct = ""; // 朝向
    if (document.getElementById("cbDirect").checked) direct = $("#div5_sDirect").text();

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerCustomer.ashx',
        data: 'act=customer_match&page=' + currentPage + '&pagesize=' + pageSize + '&area=' + area + '&dname=' + dname + '&usage=' + usage + '&buildname=' + buildname + '&tradetype=' + tradetype + '&minPrice=' + minPrice + '&maxPrice=' + maxPrice + '&minAcreage=' + minAcreage + '&maxAcreage=' + maxAcreage + '&room=' + room + '&direct=' + direct,
        timeout: '30000',
        error: function() {
            alert("匹配失败！");
        },
        success: function(json) {
            showCustomerCallBack(json);
        }
    });
}

function showCustomerCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    var page = json.page;

    currentPage = page.currentpage;
    pageall = parseInt(page.pageall);
    total = page.total;
    if (record == null || record.length == 0) {
        $("#div5_page").html(""); // 清空
        $("#div5_list").html("<strong><font color='red'>未匹配到合适的客户</font></strong>");
        return;
    }

    var arr = [];

    arr.push("<table id='tableList' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("编号</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("客户名称</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("所属人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("所属人电话</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("等级</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("购买动机</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("付佣方式</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("意向楼盘</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("意向片区</td>");
    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0) arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' >");
        else arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' >");

        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].id + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("<a href=\"javascript:showCustomerDialog(" + record[i].id + ")\" >" + record[i].customer + "</a></td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].owner + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].ownertel + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].customerclass + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].buyingmotive + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].paytype + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].estates + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].area + "</td>");
        arr.push("</tr>");
    }
    arr.push("</table>");
    $("#div5_list").html(arr.join('')); // 显示列表
    $("#div5_page").html(""); // 清空
    if (pageall > 1) {
        var pageHtml = LexunJS.showPage2(currentPage, pageall, "showCustomer"); // 分页
        $("#div5_page").html(pageHtml);
    }
}

// 弹出窗口,查看某匹配出的客源详细
function showCustomerDialog(id) {
    var url = "../CM/CustomerDetail.aspx?id=" + id;

    self.parent.closeTab('客源详情');
    self.parent.addTab('客源详情', url, 'icon-nav');
}

//弹出层
function openDiv(isValid) {
    document.getElementById("isValid").value = isValid;
    openLayer("divAlert3", "divLayer");
}

// 单选
function cbSelect(obj, objvalue) {
    if (obj.checked) {
        document.getElementById("fid").value = "";
        LexunJS.addOrCutData(1, "fid", objvalue);
    } else {
        LexunJS.addOrCutData(0, "fid", objvalue);
    }
}

// 全选
function cbSelectAll() {
    document.getElementById("fid").value = "";
    var cbAll = document.getElementById("checkboxAll");
    var checkList = document.getElementsByTagName("input");

    if (cbAll.checked) {
        for (var i = 0; i < checkList.length; i++) {
            if (checkList[i].type == "checkbox") {
                checkList[i].checked = true;
                if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(1, "fid", checkList[i].id);
            }
        }
    } else {
        for (var i = 0; i < checkList.length; i++) {
            if (checkList[i].type == "checkbox") {
                checkList[i].checked = false;
                if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(0, "fid", checkList[i].id);
            }
        }
    }
}
// 全选
function cbSelectAlls() {
    document.getElementById("fid").value = "";
    var cbAll = document.getElementById("checkboxAlls");
    var checkList = document.getElementsByTagName("input");

    if (cbAll.checked) {
        for (var i = 0; i < checkList.length; i++) {
            if (checkList[i].type == "checkbox") {
                checkList[i].checked = true;
                if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(1, "fid", checkList[i].id);
            }
        }
    } else {
        for (var i = 0; i < checkList.length; i++) {
            if (checkList[i].type == "checkbox") {
                checkList[i].checked = false;
                if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(0, "fid", checkList[i].id);
            }
        }
    }
}

// 删除跟进
function del() {
    var IDList = document.getElementById("fid").value;
    document.getElementById("fid").value = "";

    if (IDList == "") {
        alert("请先选择您要删除的行！");
        return;
    }
    hiConfirm("您确定要删除该行，请谨慎操作！", "确认框", function(result) {
        if (result) {
            // ajax删除                   
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=del&id=' + IDList,
                timeout: '10000',
                error: function() {
                    alert("删除失败！");
                },
                success: function(outmsg) {
                    alert(outmsg);
                    ShowFollow(currentPage);

                }
            });
        }
    });
}

// 删除提醒
function delAlert() {
    var IDList = document.getElementById("fid").value;
    document.getElementById("fid").value = "";

    if (IDList == "") {
        alert("请先选择您要删除的行！");
        return;
    }
    hiConfirm("您确定要删除该行，请谨慎操作！", "确认框", function(result) {
        if (result) {
            // ajax删除                   
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=delAlert&id=' + IDList,
                timeout: '10000',
                error: function() {
                    alert("删除失败！");
                },
                success: function(outmsg) {
                    alert(outmsg);
                    ShowAlert(currentPage);

                }
            });
        }
    });
}

//处理举报
function UpdateInfo() {
    var isValid = document.getElementById("isValid").value;
    var dView = document.getElementById("dView").value;
    var dResult = "";
    if (isValid == 2) {
        dResult = "不通过";
    } else if (isValid == 0) {
        dResult = "通过";
    }
    var dept = document.getElementById("ddept").value;
    var deptid = document.getElementById("ddeptid").value;
    var user = document.getElementById("duser").value;
    var userid = document.getElementById("duserid").value;
    var IDList = document.getElementById("fid").value;
    document.getElementById("fid").value = "";

    if (IDList == "") {
        alert("请先选择您要处理的行！");
        return;
    }
    // ajax删除                   
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=UpdateInfo&id=' + IDList + '&dept=' + dept + '&deptid=' + deptid + '&user=' + user + '&userid=' + userid + '&isValid=' + isValid + '&dView=' + dView + '&dResult=' + dResult,
        timeout: '10000',
        error: function() {
            alert("处理失败！");
        },
        success: function(outmsg) {
            alert(outmsg);
            ShowInfo(currentPage);
        }
    });

}

//处理提醒
function UpdateAlert() {
    var dflag = 1; //1已处理,0未处理
    var dept = document.getElementById("ddept").value;
    var deptid = document.getElementById("ddeptid").value;
    var user = document.getElementById("duser").value;
    var userid = document.getElementById("duserid").value;
    var IDList = document.getElementById("fid").value;
    document.getElementById("fid").value = "";


    if (IDList == "") {
        alert("请先选择您要处理的行！");
        return;
    }
    // ajax修改
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=UpdateAlert&id=' + IDList + '&dept=' + dept + '&deptid=' + deptid + '&user=' + user + '&userid=' + userid + '&dflag=' + dflag,
        timeout: '10000',
        error: function() {
            alert("处理失败！");
        },
        success: function(outmsg) {
            alert(outmsg);
            ShowAlert(currentPage);
        }
    });
}

//弹出窗口 typeid 0 必须打跟进 1不需打跟进
function ShowDialogFlow(typeid) {
    var id = LexunJS.GetQueryString("id"); // 楼盘ID
    if (id <= 0) {
        alert("请选择要操作的行！");
        return;
    }

    var topLength = "210px";
    if (document.body.clientWidth > 800)
        topLength = "310px";

    var path = "EstateFlow.aspx?typeid=" + typeid + "&id=" + id;
    var parameter = "盘源跟进";
    var style = "dialogWidth:580px; dialogHeight:300px; dialogTop:" + topLength + "; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    var returnValue = window.showModalDialog(path, parameter, style);

    if (returnValue > 0) {
        go_to(3);
    }
    else {
        if (typeid == 0 || typeid == "undifined") ShowDialogFlow(0);
    }

    go_to(3);
}

function ShowDioagInfo() {
    var id = LexunJS.GetQueryString("id"); // 楼盘ID
    if (id <= 0) {
        alert("请选择要操作的行！");
        return;
    }
    var path = "EstateInfo.aspx?id=" + id;
    var parameter = "添加提醒";
    var style = "dialogWidth:570px; dialogHeight:315px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    window.showModalDialog(path, parameter, style);
    go_to(8);
}

// typeid 1当前盘转资料盘 2当前盘转无效盘
function btnStatus1_Click(typeid) {
    var id = LexunJS.GetQueryString("id"); // 楼盘ID
    if (id <= 0) {
        alert("请选择要操作的行！");
        return;
    }
    var path = "HousingChangeReason.aspx?typeid=" + typeid + "&id=" + id;
    var parameter = "转盘原因";
    var style = "dialogWidth:500px; dialogHeight:230px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    window.showModalDialog(path, parameter, style);
    go_to(3);
}
//转成交盘
function ToDeal(obj) {
    if (obj.value == '转成交') {
        var id = LexunJS.GetQueryString("id"); // 楼盘ID
        if (id <= 0) {
            alert("请选择要操作的行！");
            return;
        }
        var path = "HousingToDeal.aspx?hid=" + id;
        var parameter = "转成交盘原因";
        var style = "dialogWidth:500px; dialogHeight:290px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
        window.showModalDialog(path, parameter, style);
        window.location.reload();
        return false;
    } else {
        if (confirm('确认取消成交盘!')) {
            window.location.reload();
            return true;
        }
        else {
            return false
        }
        return false;
    }
}
//弹出窗口 上传室内图
function ShowDialogPic(typeid, typename) {
    var id = LexunJS.GetQueryString("id");
    if (id <= 0) {
        alert("请选择要操作的行！");
        return;
    }

    var count = 0;
    if (typeid == 2) {
        count = photocountHXT;
    }
    else {
        count = photocount;
    }

    var path = "../swfupload/index.aspx?url=" + encodeURIComponent("~/TM/savephoto.aspx?type=" + typeid + "&id=" + id + "&typename=" + typename) + "&type=" + typeid + "&id=" + id + "&typename=" + typename + "&photocount=" + count;
    var parameter = "";
    var style = "dialogWidth:538px; dialogHeight:563px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    window.showModalDialog(path, parameter, style);
    go_to(4);
}

function ShowDialogHousingPic(typeid, typename) {
    var id = LexunJS.GetQueryString("id");
    if (id <= 0) {
        alert("请选择要操作的行！");
        return;
    }

    var path = "HousingPic.aspx?id=" + id + "&type=2";
    var parameter = "";
    var style = "dialogWidth:538px; dialogHeight:563px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    window.showModalDialog(path, parameter, style);
    go_to(4);
}

// 房屋照片
function showHousingPic(divId) {
    var id = LexunJS.GetQueryString("id");
    photocount = $("#hAllowPhotoCount").val();
    $("#" + divId).html("<img src=\"../images/loading.gif\" />"); // 清空列表 
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=housingpic_list&eid=' + id,
        timeout: '10000',
        error: function() {
            alert("查询失败！");
        },
        success: function(json) {
            showHousingPicCallBack(json, divId);
        }
    });
}


function savepic(o) {
    if (confirm('确定要下载图片？')) {
        pic = window.open(o.href, "demo")
        setTimeout('pic.document.execCommand("saveas")', 0);
    }
    return false; 
}   
function showHousingPicCallBack(response, divId) {
    var json = eval("(" + response + ")");
    var record = json.record;
    var duserid = document.getElementById("duserid").value;
    var ddeptid = document.getElementById("ddeptid").value;
    var isUploadPic = $("#hCompetencesIsUploadPic").val(); // 0不允许上传图片 1允许上传图片
    var isDelPic = $("#hCompetencesIsDelPic").val(); // 0不允许删除本部图片 1允许删除本部图片
    var AllisDelPic = document.getElementById("hCompetencesAllIsDelPic").value; //删除全部图片

    var arr = [];
    if (isUploadPic != 1) {
        $("#div4Btn").html("");
    }

    if (record == null || record.length == 0) {
        $("#" + divId).html("还没有上传图片!");
        return;
    }

    $("#" + divId).html("");
    arr.push("<br/><ul class='youxi_left_ul'>");
    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        arr.push("<li>");
        if (record[i].type == 1) {
            arr.push("<a href='javascript:showPhotoDetail(" + record[i].hid + "," + i + ")'><img id='img" + record[i].id + "' title='室内图' style='width:120px;' src='../" + record[i].picurl + "' /></a>");
            arr.push("<br/>" + record[i].remark + "   <br/>上传人:" + record[i].user + "[" + record[i].dept + "]<br/>上传时间:" + record[i].createdate)
            arr.push("<a href=\"../" + record[i].picurl + "\" onclick=\"savepic(this);return   false;\"  title='点右键目标另存为即可下载'><font color='blue'>下载</font></a>");

            if ((record[i].deptid == ddeptid && isDelPic == 1) || record[i].userid == duserid || AllisDelPic == "1") { //删除图片
                arr.push("<a href=\"javascript:DelPic(" + record[i].id + "," + record[i].userid + ");\" ><font color='red'>删除</font></a>");
            }
            photocount--;
        } else if (record[i].type == 2) {

            arr.push("<a href='javascript:showPhotoDetail(" + record[i].hid + "," + i + ")'><img id='img" + record[i].id + "' title='户型图' style='width:120px;' src='../" + record[i].picurl + "' /></a>");
            arr.push("<br/>户型图   <br/>上传人:" + record[i].user + "[" + record[i].dept + "]<br/>上传时间:" + record[i].createdate)
            arr.push("<a href=\"../" + record[i].picurl + "\"  onclick=\"savepic(this);return   false;\"   >下载</a>");

            if ((isDelPic == 1 && record[i].deptid == ddeptid) || record[i].userid == duserid || AllisDelPic == "1") { //删除图片
                arr.push("<a href=\"javascript:DelPic(" + record[i].id + "," + record[i].userid + ");\"><font color='red'>删除</font></a>");
            }
            photocountHXT--;
        }
        arr.push("</li>");
    }
    arr.push("</ul>");

    $("#" + divId).html(arr.join('')); // 显示列表

    if (photocount <= 0) {
        $("#btnUpHousingPhoto").hide();
    }
    if (photocountHXT <= 0) {
        $("#btnUpHXT").hide();
        $("#btnSelHXT").hide();
    }

}

// 小区户型
function showEstatePic(typeid, divId) {
    var id = LexunJS.GetQueryString("id");
    $("#" + divId).html("<img src=\"../images/loading.gif\" />"); // 清空列表 
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=estatepic_list&eid=' + id + '&type=' + typeid,
        timeout: '10000',
        error: function() {
            alert("查询失败！");
        },
        success: function(json) {
            showEstatePicCallBack(json, divId);
        }
    });
}

function showEstatePicCallBack(response, divId) {
    var json = eval("(" + response + ")");
    var record = json.record;
    var arr = [];
    arr.push("<ul class='youxi_left_ul'>");
    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        if (i % 6 == 0 && i > 0)
            arr.push("</ul><ul class='youxi_left_ul'>");
        arr.push("<li>");
        arr.push("<img id='img" + record[i].id + "' style='width:100px;height:80px;' src='../" + record[i].picurl + "' />");
        arr.push("</li>");
    }
    arr.push("</ul>");
    if (divId == "div5") arr.push("<ul><a href=\"javascript:ShowDialogPic(1,'estate');\"><strong><font color='red'>上传户型图</font></strong></a><ul>");

    $("#" + divId).html(arr.join('')); // 显示列表
}

//钥匙信息
function ShowKeys(divId) {
    var id = LexunJS.GetQueryString("id");
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=p_housingKey_list_table&eid=' + id + '&pageSize=' + pageSize + '&page=' + currentPage,
        timeout: '10000',
        error: function() {
            alert("查询失败！");
        },
        success: function(json) {
            ShowKeysCallBack(json);
        }
    });
}

function ShowKeysCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;
    var page = json.page;
    var receiver = document.getElementById("duser").value;
    currentPage = page.currentpage;
    pageall = parseInt(page.pageall);
    total = page.total;
    if (record == null || record.length == 0) return;
    $("#divkey1").html(""); // 显示列表
    var arr = [];
    arr.push("<table id='tableList' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("钥匙编号</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("借钥匙时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("借钥匙部门</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("借钥匙人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("借出人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("状态</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("还钥匙时间</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("接收人</td>");
    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");
        else
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");

        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].keyno + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].borrowdate + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].borrowerdept + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].borrower + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].operator + "</td>");
        arr.push("<td  height='25'  class='STYLE10'>");
        if (record[i].status == "0") {
            if (record[i].operator == receiver) {
                arr.push("<a href=\"javascript:ShowKeyDialog('HousingKey.aspx','" + record[i].id + "',1)\"><font color='red'>还钥匙</font></a></td>");
            } else {
                arr.push("<font color='red'>未还</font></a></td>");
            }
        } else {
            arr.push("<font color='blue'>已还</font></td>");
        }
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].revertdate + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].receiver + "</td>");
        arr.push("</tr>");
    }
    arr.push("</table>");
    $("#divkey1").html(arr.join('')); // 显示列表
    $("#divkey2").html(""); // 清空
    if (pageall > 1) {
        var pageHtml = LexunJS.showPage2(currentPage, pageall, "ShowKeys"); // 分页
        $("#divkey2").html(pageHtml);
    }
}

// 成交信息
function ShowTranctionDetail() {
    var id = $("#hID").val();

    if (id <= 0)
        return;

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=housingTranction_detail&pty_id=' + id,
        timeout: '10000',
        error: function() {
            alert("系统繁忙，请稍候后试！");
        },
        success: function(json) {
            ShowTranctionDetailCallBack(json);
        }
    });
}

function ShowTranctionDetailCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) return;

    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        $("#sPfyx").text(record[i].pfyx + record[i].pfqy + record[i].pffh);
        $("#sDdate").text(record[i].ddate);
        $("#sMname").text(record[i].mname);
        $("#sDtype").text(record[i].dtype);
        $("#sBuyuse").text(record[i].buyuse);
        $("#sPaystate").text(record[i].paystate);
        $("#sKty_id").text('');
        $("#sKname").text('');
        $("#sDid").text(record[i].did);
    }
}

// 同业主盘源
function showOtherHousing() {
    var id = $("#hID").val();

    if (id <= 0)
        return;

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=showOtherHousing&id=' + id,
        timeout: '30000',
        error: function() {
            alert("系统繁忙，请稍候后试！");
        },
        success: function(json) {
            showOtherHousingCallBack(json);
        }
    });
}

function showOtherHousingCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;

    if (record == null || record.length == 0) {
        $("#div7").html("该业主暂无其它盘源！"); // 清空
        return;
    }

    var arr = [];
    arr.push("<table id='tableList' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("楼盘</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("栋阁</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("楼层</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("房号</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("户型</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("交易类型</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("盘源状态</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("城区</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("片区</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("开盘人</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("开盘部门</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("开盘时间</td>");
    arr.push("</tr>");
    for (var i = 0; i < record.length; i++) {
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");
        else
            arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + record[i].id + "')\" >");

        arr.push("<td height='25'  class='STYLE10'>");        
        arr.push("<a href='#' onclick=\"openDetail('" + record[i].id + "')\">" + record[i].ename + "</a></td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].buildname + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].mark1 + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].roomno + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + arr.push(record[i].room + "-" + record[i].hall + "-" + record[i].restroom + "-" + record[i].balcony) + "</td>");
        arr.push("<td  height='25' class='STYLE6'>");
        if (record[i].tradetype == 1)
            arr.push("出售");
        else if (record[i].tradetype == 2)
            arr.push("出租");
        arr.push("</td>");

        arr.push("<td  height='25' class='STYLE6'>");
        if (record[i].status == 1)
            arr.push("当前盘");
        else if (record[i].status == 2)
            arr.push("资料盘");
        else if (record[i].status == 3)
            arr.push("无效盘");        
        arr.push("<td height='25'  class='STYLE10'>");        
        arr.push("" + record[i].dname + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].area + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].markuser + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].markudept + "</td>");
        arr.push("<td height='25'  class='STYLE10'>");
        arr.push("" + record[i].markdate + "</td>"); 
    }
    arr.push("</table>");

    $("#div7").html(""); // 清空
    $("#div7").html(arr.join(''));    
}

//弹出窗口(钥匙)
function ShowKeyDialog(url, kid, typeid) {
    var id = LexunJS.GetQueryString("id");
    if (id <= 0) {
        alert("请选择楼盘！");
        return;
    }
    var path = url + "?id=" + id + '&kid=' + kid + '&type=' + typeid;
    var parameter = "添加钥匙借记信息";
    var style = "dialogWidth:450px; dialogHeight:290px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    window.showModalDialog(path, parameter, style);
    go_to(9);
}

//收钥匙登记
function RegisterKeyDialog() {
    var id = LexunJS.GetQueryString("id");
    if (id <= 0) {
        alert("请选择盘源！");
        return;
    }
    var path = "RegisterKey.aspx?id=" + id;
    var parameter = "收钥匙登记";
    var style = "dialogWidth:450px; dialogHeight:320px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
    window.showModalDialog(path, parameter, style);
    showDetail(id);
    go_to(9);
}

function DelPic(id, userid) { //删除图片
    hiConfirm("您确定要删除该图片，请谨慎操作！", "确认框", function(result) {
        if (result) {

            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=DelPic&id=' + id + '&userid=' + userid,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙，请稍候后试！");
                },
                success: function(json) {
                    alert(json);
                    go_to(4);
                }
            });
        }
    });
}

//资料转当前盘
function toPty() {
    obj = document.getElementById('dvToPty')
    if (obj.style.display == 'block') {
        obj.style.display = 'none';
    }
    else {
        $("#tbMakeUser").autocomplete("../Ajax/GetUserAuto.aspx", { minChars: 2, extraParams: { exists: '1', uname: function() { return escape($('#tbMakeUser').val()); } }, scrollHeight: 350, width: 230, max: 100 });
        obj.style.display = 'block';
        $("#tbMakeUser").focus();
    }
    return false;
}

//资料转当前盘,验证开盘人
function chkToPty() {
    var objValue = document.getElementById('tbMakeUser').value;

    if (objValue == "") {
        alert("开盘人不能为空!");
        return false;
    }
}

function showPhotoDetail(hid, num) {
    var path = "HousingPicDetail.aspx?id=" + hid + "&num=" + num;
    var parameter = "盘源图片";
    var style = "dialogWidth:600px; dialogHeight:550px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";

    window.showModalDialog(path, parameter, style);
}


//弹出窗口 (举报)
function ShowDialog() {
    var IDList = document.getElementById("hID").value;

    if (IDList == "") {
        alert("您要举报的房源不存在！");
        return false;
    }
    var path = "EstateShowInfo.aspx?hid=" + IDList + '&deptid=0';
    var parameter = "盘源举报";
    var style = "dialogWidth:450px; dialogHeight:230px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";

    window.showModalDialog(path, parameter, style);
}




// 删除
function delHousing() {
    var IDList = document.getElementById("hID").value;
    if (IDList == "") {
        alert("请先选择您要删除的行！");
        return false;
    }

    hiConfirm("您确定要删除该行，请谨慎操作！", "确认框", function(result) {
        if (result) {
            // ajax删除                   
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=housing_del&id=' + IDList,
                timeout: '10000',
                error: function() {
                    alert("删除失败！");
                }, success: function(outmsg) {
                    alert(outmsg);
                }
            });
        }
    });

    return false;
}

//弹出窗口 (笋盘推荐)
function ShowDialogListing(obj) {
    var IDList = document.getElementById("hID").value;
    var idlist = IDList.split('|');
    var idleng = idlist.length - 1;
    var id = idlist[0];
    document.getElementById("hID").value = "";
    if (idleng > 1) {
        alert("只能选择一行！");
        return false;
    }
    if (id == "") {
        alert("请先选择您要推荐的房源！");
        return false;
    }
    if (obj.value == '推荐') {
        var path = "Listing.aspx?hid=" + id;
        var parameter = "笋盘推荐";
        var style = "dialogWidth:450px; dialogHeight:230px; status:0;scroll:1; help:0; resizable:1;Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no";
        window.showModalDialog(path, parameter, style);
        window.location.reload();
        return false;
    } else {
        if (confirm('确认取消推荐盘!')) {
            window.location.reload();
            return true;
        }
        else {
            return false
        }
        return false;
    }
}

// 收藏盘 0取消收藏 1收藏
function favorite(id, isfavorite) {
    var outmsg = "收藏";
    var IDList = document.getElementById("hID").value;

    if (isfavorite == 0) {
        outmsg = "取消收藏";
    } else {
        if (IDList == "") {
            alert("请先选择您要" + outmsg + "的盘源！");
            return false;
        }
    }

    hiConfirm("您确定要" + outmsg + "该盘源，请谨慎操作！", "确认框", function(result) {
        if (result) {
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=housing_favorite&idlist=' + IDList + '&id=' + id + '&isfavorite=' + isfavorite,
                timeout: '10000',
                error: function() {
                    alert(outmsg + "失败！");
                }, success: function(outmsg) {
                    alert(outmsg);
                }
            });
        }
    });

    return false;
}

// 每日一盘
function everyday() {
    var IDList = document.getElementById("hID").value;

    if (IDList == "") {
        alert("请先选择您要推荐到每日一盘的盘源！");
        return false;
    }

    hiConfirm("您确定要推荐该盘源到每日一盘，请谨慎操作！", "确认框", function(result) {
        if (result) {
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=housing_everyday_add&id=' + IDList,
                timeout: '10000',
                error: function() {
                    alert("推荐失败");
                }, success: function(outmsg) {
                    alert(outmsg);
                }
            });
        }
    });

    return false;
}

// 封盘
function lock(obj) {
    var IDList = document.getElementById("hID").value;
    if (IDList == "") {
        alert("请先选择您要封锁的盘源！");
        return false;
    }
    if (obj.value == '封盘') {
        hiConfirm("您确定要封锁该盘源，请谨慎操作！", "确认框", function(result) {
            if (result) {
//                // ajax删除                   
//                $.ajax({
//                    type: 'POST',
//                    url: '../Handler/HandlerHousing.ashx',
//                    data: 'act=housing_lock&isProtected=1&id=' + IDList,
//                    timeout: '10000',
//                    error: function() {
//                        alert("封盘失败！");
//                    }, success: function(outmsg) {
//                        alert(outmsg);
//                        window.location.reload();
//                    }
                //                });
                var path = "HousingLockInput.aspx?id=" + IDList;
                var parameter = "转成交盘原因";
                var style = "dialogWidth:500px; dialogHeight:290px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
                window.showModalDialog(path, parameter, style);
                window.location.reload();
            }
        });

        return false;
    } else {
        if (confirm('确认取消封盘!')) {
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerHousing.ashx',
                data: 'act=housing_lock&isProtected=0&id=' + IDList,
                timeout: '10000',
                error: function() {
                    alert("封盘失败！");
                }, success: function(outmsg) {
                    alert(outmsg);
                    window.location.reload();

                }
            });
        }
        else {
            return false
        }
        return false;
    }
}

// 打开高级查询框
function iAdvancedSearch_onclick() {
    var obj = document.getElementById("divAdvancedSearch");
    $("#divAdvancedSearch").toggle();
}

//清文本框
function ClearText(obj) {
    obj.value = "";
}

//标记无效
function UIsValid() {

    var Mark = document.getElementById("Mark").value; //0:有效，1无效
    var hid = document.getElementById("hID").value;

    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerHousing.ashx',
        data: 'act=UpdateMark4&id=' + hid + '&mark4=' + Mark,
        timeout: '10000',
        error: function() {
            alert("操作失败！");
        }, success: function() {
            window.location.reload();
        }
    });
}

// 查看详情
function openDetail(id) {
    $("tr").removeClass("selected");
    $("#tr_" + id).addClass("selected");

    var id_list = $("#hID_List").val();
    var url = "../PM/HousingDetail.aspx?id=" + id + "&id_list=" + escape(id_list);
    var style = "left = 50, screenX = 0, top = 50, screenY = 0, resizable = yes, scrollbars = yes,width=750px, height=600px,Toolbar=no,Location=no,Direction=no,Resizeable=no";

    window.open(url, '', style);

//    self.parent.closeTab('盘源详情[' + id + ']');
//    self.parent.addTab('盘源详情[' + id + ']', url, 'icon-nav');
}